import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:util_plugin/hex_color.dart';

class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
  final String title;
  final Widget? leading;
  final bool? centerTitle;
  final Color? backgroundColor;
  final double? elevation;
  final double? leadingWidth;
  final PreferredSizeWidget? bottom;
  final List<Widget> actions;

  const CustomAppBar(
      {super.key,
      this.title = '',
      this.backgroundColor = Colors.white,
      this.centerTitle = true,
      this.elevation,
      this.leading,
      this.leadingWidth,
      this.bottom,
      this.actions = const []});

  @override
  Widget build(BuildContext context) {
    return AppBar(
      backgroundColor: backgroundColor,
      centerTitle: centerTitle,
      elevation: elevation,
      leadingWidth: leadingWidth,
      title: Text(
        title,
        style: TextStyle(
            fontSize: 18.sp,
            fontWeight: FontWeight.bold,
            color: HexColor('#333333')),
      ),
      leading: leading,
      actions: actions,
      bottom: bottom,
    );
  }

  @override
  Size get preferredSize =>
      Size.fromHeight(kToolbarHeight + (bottom?.preferredSize.height ?? 0));
}
